package com.zzj.controller;

import com.zzj.bean.TeamBean;
import com.zzj.service.TeamService;
import com.zzj.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.*;

@EnableDiscoveryClient
@RestController
@RequestMapping("team")
public class TeamController {
    @Autowired
    private TeamService teamService;

    /**
     * 添加一个班组
     * @param teamBean
     * @return
     */
    @PostMapping("addTeam")
    public Result addTeam(TeamBean teamBean){
        return teamService.addTeam(teamBean);
    }

    /**
     * 删除一个班组
     * @param tid
     * @return
     */
    @PostMapping("delTeam")
    public Result delTeam(int tid){
        return teamService.delTeamByTid(tid);
    }

    /**
     * 更改一个班组信息
     * @param teamBean
     * @return
     */
    @PostMapping("updTeam")
    public Result updTeam(TeamBean teamBean){
        return teamService.updTeam(teamBean);
    }

    /**
     * 查看全部班别信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("findAllTeam")
    public Result findAllTeam(@RequestParam(defaultValue = "1") Integer pageNum,
                              @RequestParam(defaultValue = "5") Integer pageSize){
        return teamService.findAll(pageNum, pageSize);
    }

    /**
     * 通过ID查看班别信息
     * @param did
     * @return
     */
    @GetMapping("findByDid")
    public Result findById(int did){
        return teamService.findTeamByDid(did);
    }

    @GetMapping("findTeamByTid")
    public Result findTeamByTid(int tid){
        return teamService.findTeamByTid(tid);
    }
}
